﻿namespace YunQue.DataBase.Configuration
{
    /// <summary>
    /// 基类实体配置
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public class BaseEntityConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : BaseEntity
    {
        /// <summary>
        /// 数据库实体配置
        /// </summary>
        /// <param name="builder"></param>
        public virtual void Configure(EntityTypeBuilder<TEntity> builder)
        {
            builder.HasKey(e => e.Id); 
            builder.Property(e => e.Id).HasColumnName("id").HasMaxLength(100).HasColumnType("varchar").HasComment("主键").IsRequired();
            builder.Property(e => e.CreateUserId).HasColumnName("create_user_id").HasMaxLength(100).HasColumnType("varchar").HasComment("创建人").IsRequired();
            builder.Property(e => e.CreateTime).HasColumnName("create_time").HasColumnType("datetime").HasComment("创建时间").IsRequired();
            builder.Property(e => e.UpdateUserId).HasColumnName("update_user_id").HasMaxLength(100).HasColumnType("varchar").HasComment("更新人");
            builder.Property(e => e.UpdateTime).HasColumnName("update_time").HasColumnType("datetime").HasComment("更新时间");
            builder.Property(e => e.IsDeleted).HasColumnName("is_deleted").HasColumnType("bit").IsRequired().HasComment("是否删除");
            builder.Property(e => e.TenantCode).HasColumnName("tenant_code").HasMaxLength(100).HasColumnType("varchar").IsRequired().HasComment("租户编码");
        }
    }
}
